﻿<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <!-- Codice Contratto Dispacciamento come definito da Terna -->
  <xs:simpleType name="CodContrDispType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="6"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Codice POD per esempio IT 123 E 12345678 -->
  <xs:simpleType name="CodicePodType">
    <xs:restriction base="xs:string">
      <xs:minLength value="14"/>
      <xs:maxLength value="15"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Codice Tariffa -->
  <xs:simpleType name="CodiceTariffaType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="30"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Data (Formato italiano dd/MM/yyyy) -->
  <xs:simpleType name="DataItaType">
    <xs:restriction base="xs:string">
      <xs:pattern value="(0[1-9]|[12][0-9]|3[01])[//](0[1-9]|1[012])[//](19|20)\d\d"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Dst: 0=no DST     - potenziali 96 quarti d'ora;
            1=Inizio DST - potenziali 92 quarti d'ora;
            2=Fine DST   - Prima parte curva;
            3=Fine DST   - Seconda parte curva -->
  <xs:simpleType name="DstType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="0"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="2"/>
      <xs:enumeration value="3"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Giorno (Formato dd) -->
  <xs:simpleType name="GiornoType">
    <xs:restriction base="xs:string">
      <xs:pattern value="(0[1-9]|[12][0-9]|3[01])"/>
    </xs:restriction>
  </xs:simpleType>
  <!--  Alfanumerico 3. Formato: 3 cifre (massimo) -->
  <xs:simpleType name="Intero3Type">
    <xs:restriction base="xs:integer">
      <xs:pattern value="[1-9]\d{0,2}|[0]{1}"/>
    </xs:restriction>
  </xs:simpleType>
  <!--  Alfanumerico 10. Formato: 10 cifre (massimo) -->
  <xs:simpleType name="Intero10Type">
    <xs:restriction base="xs:integer">
      <xs:pattern value="[1-9]\d{0,9}|[0]{1}"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Matricola Misuratore -->
  <xs:simpleType name="MatrMisType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="17"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Mese Anno (Formato italiano MM/yyyy) -->
  <xs:simpleType name="MeseAnnoItaType">
    <xs:restriction base="xs:string">
      <xs:pattern value="(0[1-9]|1[012])[//](19|20)\d\d"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Motivazione rettifica -->
  <xs:simpleType name="MotivazioneType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="1"/>
      <xs:enumeration value="2"/>
      <xs:enumeration value="3"/>
      <xs:enumeration value="4"/>
      <xs:enumeration value="5"/>
    </xs:restriction>
  </xs:simpleType>
  <!--  Alfanumerico 10. Formato: 6 cifre (massimo), Virgola, 3 cifre -->
  <xs:simpleType name="Numerico6v3Type">
    <xs:restriction base="xs:string">
      <xs:pattern value="[1-9]\d{0,5}[,][0-9]{3}|[0][,][0-9]{3}"/>
    </xs:restriction>
  </xs:simpleType>
  <!--  Alfanumerico 11. Formato: 7 cifre (massimo), Virgola, 3 cifre -->
  <xs:simpleType name="Numerico7v3Type">
    <xs:restriction base="xs:string">
      <xs:pattern value="[1-9]\d{0,6}[,][0-9]{3}|[0][,][0-9]{3}"/>
    </xs:restriction>
  </xs:simpleType>
  <!--  Alfanumerico 16. Formato: 12 cifre (massimo), Virgola, 3 cifre -->
  <xs:simpleType name="Numerico12v3Type">
    <xs:restriction base="xs:string">
      <xs:pattern value="[1-9]\d{0,11}[,][0-9]{3}|[0][,][0-9]{3}"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Tipo Semplice con scelta SI/NO -->
  <xs:simpleType name="OnOffType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="SI"/>
      <xs:enumeration value="NO"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Partita IVA -->
  <!-- Validato solo sulla lunghezza (11) e il tipo dato (numerico) -->
  <xs:simpleType name="PIVAType">
    <xs:restriction base="xs:string">
      <xs:pattern value="\d{11}"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Punto Dispacciamento -->
  <xs:simpleType name="PuntoDispacciamentoType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="NORD"/>
      <xs:enumeration value="CNOR"/>
      <xs:enumeration value="CSUD"/>
      <xs:enumeration value="SUD"/>
      <xs:enumeration value="SICI"/>
      <xs:enumeration value="SARD"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Raccolta -->
  <xs:simpleType name="RaccoltaType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="P"/>
      <xs:enumeration value="T"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Servizio Tutela -->
  <xs:simpleType name="ServizioTutelaType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="MT"/>
      <xs:enumeration value="S"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Tipo Dato -->
  <xs:simpleType name="TipoDatoType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="E"/>
      <xs:enumeration value="S"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Trattamento -->
  <xs:simpleType name="TrattamentoType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="M"/>
      <xs:enumeration value="F"/>
      <xs:enumeration value="O"/>
      <xs:enumeration value="C"/>
    </xs:restriction>
  </xs:simpleType>
  <!-- Validato -->
  <xs:simpleType name="ValidatoType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="S"/>
      <xs:enumeration value="N"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>
